<?php
/**
 * Created by PhpStorm.
 * User: yeluojun
 * Date: 14-5-11
 * Time: 上午12:21
 */

include_once dirname(__FILE__) . '/../common/common.php';

try{
    $user_id = $_REQUEST["userId"];
    $path = "pic/";
    $fileName = $user_id.".jpg";

    //删除旧文件
    if(file_exists( $path.$fileName))
    {
        unlink( $path.$fileName);
    }

    //保存文件
    move_uploaded_file($_FILES["file"]["tmp_name"],
        $path.$fileName);

    $result = MsgArray(true,"上传成功",null,"success");
    echo json_encode($result);
}catch (Exception $e){
    $a = $e->getMessage();
    $result = MsgArray(false,"上传失败",null,"Error");
    echo json_encode($result);
}
